import 'package:flutter/material.dart';

class TstNotification extends StatefulWidget {
  @override
  _TstNotificatonSate createState() => _TstNotificatonSate();
}




class _TstNotificatonSate extends State<TstNotification> {

  double _progress=0;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      backgroundColor: Colors.blue,
      appBar: AppBar(
        title: Text('滑动监听:$_progress'),
      ),
      body: NotificationListener<ScrollNotification>(
        onNotification: (ScrollNotification notification) {

          if(notification.depth==0){
            _progress = notification.metrics.pixels;

            print('=======:$_progress');
            setState(() {

            });

          }


        },
        child: ListView(
          children: <Widget>[
            Container(
                height: 250,
                child: Image(
                  image: NetworkImage(
                      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1561701368790&di=5681d29b6b802837e175dc7e7bd8680d&imgtype=0&src=http%3A%2F%2Fpicapi.zhituad.com%2Fphoto%2F66%2F41%2F07EDC.jpg'),
                  fit: BoxFit.fill,
                )),
            Container(
                height: 250,
                child: Image(
                  image: NetworkImage(
                      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1561701368790&di=5681d29b6b802837e175dc7e7bd8680d&imgtype=0&src=http%3A%2F%2Fpicapi.zhituad.com%2Fphoto%2F66%2F41%2F07EDC.jpg'),
                  fit: BoxFit.fill,
                )),
            Container(
                height: 250,
                child: Image(
                  image: NetworkImage(
                      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1561701368790&di=5681d29b6b802837e175dc7e7bd8680d&imgtype=0&src=http%3A%2F%2Fpicapi.zhituad.com%2Fphoto%2F66%2F41%2F07EDC.jpg'),
                  fit: BoxFit.fill,
                )),
            Container(
                height: 250,
                child: Image(
                  image: NetworkImage(
                      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1561701368790&di=5681d29b6b802837e175dc7e7bd8680d&imgtype=0&src=http%3A%2F%2Fpicapi.zhituad.com%2Fphoto%2F66%2F41%2F07EDC.jpg'),
                  fit: BoxFit.fill,
                )),
          ],
        ),
      ),
    );
  }
}
